unit principalu;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ImgList, Vcl.ToolWin, Vcl.ComCtrls,
  Vcl.Menus, System.Actions, Vcl.ActnList, System.ImageList;

type
  TfrmPrincipal = class(TForm)
    mmPRINCIPAL: TMainMenu;
    Arquivo1: TMenuItem;
    Cadastro1: TMenuItem;
    venda1: TMenuItem;
    Sair1: TMenuItem;
    Cliente1: TMenuItem;
    Funcionario1: TMenuItem;
    Produto1: TMenuItem;
    Relatorio1: TMenuItem;
    Clientes1: TMenuItem;
    Produtos1: TMenuItem;
    Vendas1: TMenuItem;
    Ajuda1: TMenuItem;
    Sobre1: TMenuItem;
    StatusBar1: TStatusBar;
    tbPrincipal: TToolBar;
    ilPrincipal48: TImageList;
    ilPrincipal20: TImageList;
    acPrincipal: TActionList;
    acCadCliente: TAction;
    acCadFuncionario: TAction;
    acCadProduto: TAction;
    acVenda: TAction;
    acRelCliente: TAction;
    acRelProduto: TAction;
    acRelVenda: TAction;
    acSair: TAction;
    scSobre: TAction;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    ToolButton3: TToolButton;
    ToolButton4: TToolButton;
    ToolButton5: TToolButton;
    ToolButton6: TToolButton;
    ToolButton7: TToolButton;
    ToolButton8: TToolButton;
    procedure acCadClienteExecute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure abreForm(classe : TFormClass);
  end;

var
  frmPrincipal: TfrmPrincipal;

implementation

{$R *.dfm}
  uses clienteListaU;


procedure TfrmPrincipal.abreForm(classe: tformClass);
var
i:integer;
begin

 for i := 0 to MDIchildCount -1 do begin
       if MDIChildren[i] is classe then begin //o formulario ja estar aberto

 if MDIChildren[i].windowState = wsMinimized then begin
        MDIChildren[i].windowState :=wsNormal;
end;
      MDIChildren[i].BringToFront;
    MDIChildren[i].setFocus;
   exit;
   end;
   end;
     Classe.Create(Application);

end;

procedure TfrmPrincipal.acCadClienteExecute(Sender: TObject);
begin
abreForm(TfrmClienteLista);
end;

end.


